package com.lebang.common.util;

import com.lebang.entity.RequestHeaders;
import com.lebang.entity.member.LbbMemberRecord;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: hwq
 * @Date: 2019/5/29 14:06
 * @Version 1.0
 */
public class RequestUtil {
    public static RequestHeaders getHeader(HttpServletRequest request) {
        RequestHeaders requsetHeader = new RequestHeaders(request);
        requsetHeader.setIpAddr(IpUtil.getIp(request));
        return requsetHeader;

    }

    public static RequestHeaders getHeader(LbbMemberRecord record) {
        RequestHeaders requsetHeader = new RequestHeaders();
        String appid = record.getAppId();
        String appStore = record.getAppStore();
        String version = record.getVersion();
        String imei = record.getImei();
        String macAddr = record.getMacAddr();
        String os = record.getOs();
        String osv = record.getOsv();
        String brand = "";
        String userid = record.getMemberId();
        requsetHeader.setAppid(appid == null ? "" : appid);
        requsetHeader.setAppStore(appStore == null ? "" : appStore);
        requsetHeader.setVersion(version == null ? "" : version);
        requsetHeader.setImei(imei == null ? "" : imei);
        requsetHeader.setMacAddr(macAddr == null ? "" : macAddr);
        requsetHeader.setOs(os == null ? "" : os);
        requsetHeader.setOsv(osv == null ? "" : osv);
        requsetHeader.setBrand(brand);
        requsetHeader.setUserid(userid == null ? "" : userid);
        requsetHeader.setIpAddr(record.getIpAddr());
        return requsetHeader;

    }


}
